const express = require("express");
const routers = express.Router();
const mysql = require('./pool.js');

routers.get('/list',(req,res,next)=>{

	let data = req.query;
	if(!data.page){
		data.page = 1
	}
	if(!data.count){
		res.send({code:402,msg:"总量不能为空"});
		return;
	}
	let start = (data.page-1)*data.count;
	mysql.query('select * from  xz_laptop limit ?,?',[start,data.count*1],(err,result)=>{
		if(err){
			throw err;
		}
		if(result.length === 0){
			res.send({code:404,msg:"没有该数据",data:[]});
		}else{
			res.send({code:200,msg:"查找到数据",data:result});
		}
		return;
		
	})
})

module.exports=routers;